import { FlyIconData } from './../model/ModelFlyIcon';
import { ViewBackState, ViewLayer, ViewMode } from "../../../../framework/view/ViewConsts";
import { ViewCtrlBase } from "../../../../framework/view/ViewCtrlBase";
import { GameMainEvent } from '../../../const/GameEvents';
import ViewFlyIcon from "../view/ViewFlyIcon";
import { CompositeDisposable } from '../../../../framework/event/EventKit';


export default class VCFlyIcon extends ViewCtrlBase {
    public static viewName: string = "ViewFlyIcon";
    public static viewMode: ViewMode = ViewMode.SINGLE;
    public viewLayer: ViewLayer = ViewLayer.Layer_Hud_Effect;
    public viewClass: (typeof ViewFlyIcon) = ViewFlyIcon;

    onOpen() {
        super.onOpen();
    }

    onClose() {
        super.onClose();
    }
    /**注册系统事件 */
    registEvent(): void {
        this.disposable = new CompositeDisposable();
        this.disposable.add(GameMainEvent.ON_FLY_ICON.on(this.flyIcon.bind(this)));
    }


    /**
     * @desc 检查是否可以使用返回键退出
     * 特殊情况,子类重写方法逻辑,返回ViewBackState.Close则不可以使用返回键关闭
     * @returns ViewBackState
     */
    public checkCanBack(): ViewBackState {
        return ViewBackState.Pass;
    }

    flyIcon(data: FlyIconData, callback?: () => void) {
        this.viewDoAction("flyIcon", data, callback);
    }
}